From 4bfd7b5e13ca6c45239241a26352d9b1e1acccab Mon Sep 17 00:00:00 2001 From: "awilliam@xenbuild.aw" Date: Mon, 15 May 2006 13:42:18 -0600 Subject: [PATCH] [IA64] Strengthen dom0_getmemlist reset num_pfns before hypercalling, more checks in hypercall, cleanup Signed-off-by: Tristan Gingold --- tools/libxc/xc_ia64_stubs.c | 4 +++- xen/arch/ia64/xen/dom0_ops.c | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/libxc/xc_ia64_stubs.c b/tools/libxc/xc_ia64_stubs.c index 97da325f03..58d07477cc 100644 --- a/tools/libxc/xc_ia64_stubs.c +++ b/tools/libxc/xc_ia64_stubs.c @@ -50,7 +50,7 @@ xc_plan9_build(int xc_handle, } /* VMM uses put_user to copy pfn_list to guest buffer, this maybe fail, - VMM don't handle this now. + VMM doesn't handle this now. This method will touch guest buffer to make sure the buffer's mapping is tracked by VMM, */ @@ -66,6 +66,7 @@ int xc_ia64_get_pfn_list(int xc_handle, unsigned int __start_page, __nr_pages; unsigned long max_pfns; unsigned long *__pfn_buf; + __start_page = start_page; __nr_pages = nr_pages; __pfn_buf = pfn_buf; @@ -75,6 +76,7 @@ int xc_ia64_get_pfn_list(int xc_handle, op.cmd = DOM0_GETMEMLIST; op.u.getmemlist.domain = (domid_t)domid; op.u.getmemlist.max_pfns = max_pfns; + op.u.getmemlist.num_pfns = 0; set_xen_guest_handle(op.u.getmemlist.buffer, __pfn_buf); if ( (max_pfns != -1UL) diff --git a/xen/arch/ia64/xen/dom0_ops.c b/xen/arch/ia64/xen/dom0_ops.c index 7066ab8e02..cdad3ad941 100644 --- a/xen/arch/ia64/xen/dom0_ops.c +++ b/xen/arch/ia64/xen/dom0_ops.c @@ -151,10 +151,7 @@ long arch_do_dom0_op(dom0_op_t *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op) put_domain(d); } break; - /* - * NOTE: DOM0_GETMEMLIST has somewhat different semantics on IA64 - - * it actually allocates and maps pages. - */ + case DOM0_GETMEMLIST: { unsigned long i = 0; @@ -198,7 +195,8 @@ long arch_do_dom0_op(dom0_op_t *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op) ret = -ENOMEM; op->u.getmemlist.num_pfns = i - start_page; - copy_to_guest(u_dom0_op, op, 1); + if (copy_to_guest(u_dom0_op, op, 1)) + ret = -EFAULT; put_domain(d); } -- 2.30.2